#

| Chapter 30 vi Tips and Tricks |

## 30.8 Get Back What You Deleted with Numbered Buffers

Being able to delete large blocks of text at a single bound is all very well and good, but what if you mistakenly delete 53 lines that you need? There's a way to recover any of your past nine deletions, because they're saved in numbered buffers. The last delete is saved in buffer 1, the second-to-last in buffer 2, and so on.

To recover a deletion, type `<">` (the double quote character), identify the buffered text by number, then give the put command. To recover your second-to-last deletion from buffer 2, type:

>     "2p

The deletion in buffer 2 is placed on the line below the cursor.

If you're not sure which buffer contains the deletion you want to restore, you don't have to keep typing `<">`n `p` over and over again. If you use the repeat command (`.`) with `p` after `u` (undo), it automatically increments the buffer number. As a result, you can search through the numbered buffers as follows:

>     "1pu.u.u etc.

to put the contents of each succeeding buffer in the file one after the other. Each time you type `u`, the restored text is removed; when you type a dot (.), the contents of the next buffer is restored to your file. Keep typing `u` and . until you've recovered the text you're looking for.

- TOR from O'Reilly & Associates' Learning the vi Editor, Chapter 4

30.7 Using Buffers to Move or Copy Text |  | 30.9 Using Search Patterns and Global Commands